<template>
  <div class="map_container">
    <div id="container" style="width:100vw; height:100vh"></div>
  </div>
</template>

<script>
/* eslint-disable */
import $ from 'jquery'
export default {
  data() {
    return {
      map: null,
      datas: [
        {
          id: '1',
          pos: [39.959228, 116.367874]
        },
        {
          id: '2',
          pos: [39.988169, 116.279984]
        },
        {
          id: '3',
          pos: [39.847558, 116.402893]
        },
        {
          id: '4',
          pos: [39.941857, 116.383667]
        },
        {
          id: '5',
          pos: [40.022882, 116.551208]
        },
        {
          id: '6',
          pos: [39.819085, 116.581421]
        }
      ]
    }
  },
  computed: {
    datas2() {
      return this.datas.map(v => {
        return {
          id: v.id,
          pos: [v.pos[0] + 0.01, v.pos[1] + 0.01]
        }
      })
    }
  },
  mounted() {
    this.initMap()
  },
  methods: {
    // 经纬度计算角度
    GetDistance(lat1, lng1, lat2, lng2) {
      var radLat1 = (lat1 * Math.PI) / 180.0
      var radLat2 = (lat2 * Math.PI) / 180.0
      var a = radLat1 - radLat2
      var b = (lng1 * Math.PI) / 180.0 - (lng2 * Math.PI) / 180.0
      let deg = (Math.atan(b / a) * 360) / (2 * Math.PI)
      if (radLat2 < radLat1) {
        deg = deg - 90 - 90
      } else {
        deg = deg
      }
      return deg
    },

    initMap() {
      this.map = new BMap.Map('container')
      var point = new BMap.Point(116.404, 39.915)
      this.map.centerAndZoom(point, 15)
      this.map.enableScrollWheelZoom(true)
      this.map.enableDragging()
    },
    createCluster(map) {}
  }
}
</script>

<style lang="scss" scoped>
.map_container {
}
</style>
